package com.lzw.bluetoothpractice.Activitys;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.lzw.bluetoothpractice.R;

import cn.bmob.v3.Bmob;

public abstract class BaseActivity extends Activity {
    LinearLayout iconBack,iconBack2;
    TextView tvtitle,tvtitle2;
    ImageView iconSet,iconSet2;
    Toast toast;
    /**
     * findViewById
     * @param id
     * @param <T>
     * @return
     */
    protected <T extends View> T fd(@IdRes int id ){
        return findViewById(id);
    }

    protected void InitNavBar(boolean isShowBack,String title,boolean isShowSet){

        iconBack=findViewById(R.id.navBack);
        iconSet=(ImageView)fd(R.id.navSet);
        tvtitle=fd(R.id.tvTitle);
        iconBack.setVisibility(isShowBack ? View.VISIBLE : View.GONE);
        iconSet.setVisibility(isShowSet ? View.VISIBLE : View.GONE);
        tvtitle.setText(title);
        iconBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });
        iconSet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(BaseActivity.this,RecoveryScheActivity.class));
            }
        });


    }
    protected void InitNavBar2(boolean isShowBack,String title,boolean isShowSet){

        iconBack2=findViewById(R.id.navBack2);
        iconSet2=(ImageView)fd(R.id.navSet2);
        tvtitle2=fd(R.id.tvTitle2);
        iconBack2.setVisibility(isShowBack ? View.VISIBLE : View.GONE);
        iconSet2.setVisibility(isShowSet ? View.VISIBLE : View.GONE);
        tvtitle2.setText(title);
        iconBack2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });
        iconSet2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(BaseActivity.this,DoctorsAddActivity.class));
            }
        });


    }
    private static boolean isMiUi = false;

    protected void initWindow() {

    }



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bmob.resetDomain("http://open-vip.bmob.cn/8/");
        Bmob.initialize(this, "76f6ea7dee566f989b60f81b98cf772c");

        initWindow();

    }
}
